<template>
    <div class="table-container">
     <el-drawer
     title="中压线段查询结果"
  :visible.sync="table"
  direction="rtl"
  class="right-pop-box"
  size="80%">
 <div class="dwbmTableBtn">
      <el-button
        type="primary"
        icon="el-icon-setting"
        size="mini"
        class="columnBtn"
        @click="cccEvent('show',zczyXdsjColumnTable)"
      >配置列</el-button>
      <el-button class="exportBtn" type="primary"  size="mini" @click="cccEvent('export', zczyXdsjColumnTable)">导 出</el-button>
    </div>
      <!-- <el-button type="primary" size="mini" class="right">导出</el-button>
      <el-button type="primary" size="mini" class="right">配置列</el-button> -->
   
   <el-table 
    ref="dialogTable"
   :data="tableData" 
   border
    height="calc(100% - 100px)"
    width="100%"
    class="table"
   >
   <template v-for="col in zczyXdsjColumnData">
          <el-table-column
            :show-overflow-tooltip="true"
            :key="col.id"
            :prop="col.field"
            :label="col.title"
            :min-width="col.minWidth"
            :align="col.align"
            :header-align="col.align"
            :sortable="col.sortable"
            :formatter="col.formatter"
            :fixed="col.fixed"
          ></el-table-column>
        </template>
      
    </el-table>

    <!-- 分页-->
     <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page.currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="page.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="page.total">
    </el-pagination>

</el-drawer>
<ccc ref="ccc"></ccc>
    </div>
</template>
           
<script>
import {getZczyTable} from '@/api/sjwh/zczy.js'
import { dataModulePrefix } from '../../../../config'
import ccc from '@/dialogCommom/ccc'
export default {
  props:{
    //接收查询参数
    tableData:{
      type:Array,
      default:function(){
        return{}
      }
    }
  },
  data() {
    return {
     page:{ 
      size:10,
      total:0,
      currentPage: 1
      },
      table: false,
      dialog: false,
      loading: false,
      gridData: [],
      zczyXdsjColumnData:[],
      zczyXdsjColumnTable: 'zc_zyxdsj', // 中压注册线段列配置参数
      formLabelWidth: '80px',
      timer: null
    };
  },
  created() {
    // this.getTableList()
    this.cccEvent("load",this.zczyXdsjColumnTable)
  },
  components:{
    ccc
  },
  //解决列配置引发的滚动条问题
  beforeUpdate() {
   /*  this.$nextTick(()=>{
      this.$refs.dialogTable.doLayout()
    }) */
  },
  methods: {
    //列配置
    cccEvent(method, table) {
      if (method === "show") {
        this.$refs.ccc.show(table);
      } else if (method === "load") {
        new Promise((resolve, reject) => {
          this.$nextTick(() => {
            resolve(this.$refs.ccc.load(table));
          });
        }).then(response => {
          this.zczyXdsjColumnData = response;
        });
      } else if (method === "export") {
        //导出问题
        let vo = {
          tableCode: table,
          param: this.tableData,
          url: `${dataModulePrefix}/zc-zyxdsj/page`,
          method: "POST",
          fileName: '中压注册线段',
          total: this.page.total
        };
        this.$refs.ccc.exportExcel(vo);
      }
    },
    handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        this.page.size = val
       this.$emit("getTableChange",this.page)
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.page.currentPage = val
        this.$emit("getTableChange",this.page)
      },
  
  }
}
</script>
<style scoped lang="scss">
.el-table th.gutter {
  display: table-cell !important;
}
.el-table colgroup.gutter {
  display: table-cell !important;
}
.dwbmTableBtn{
    margin-left: 20px;
    float: right;
    margin-bottom: 5px;
}
.table-container {
  width:100%;
  height:100%;
}
.table {
  // margin-left:10px;
  margin-bottom:10px
}
/deep/.el-drawer__header { 
    margin-bottom: 0 ;
}
.right-pop-box {
    /deep/ .el-drawer__header { 
      span {
        outline: none;
      }
    }
  }
</style>